
MOD_INTERF_MAGIC		equ 187561
MOD_INTERF_MAGIC_LEN		= 3

MOD_INTERF_VERSION		equ 1
MOD_INTERF_VERSION_LEN		= 1

MOD_INTERF_CREATING_OFFSET	= MOD_INTERF_MAGIC_LEN+MOD_INTERF_VERSION_LEN

MOD_INTERF_CR_BEGINING_SIZE	equ 4*1024*1024


;-------------------------------------------------------
_@mod_interf_cr_chunk_begin_stack_el struc
	cnkPtr			dd 0
	lpNext_chunkBeg_stackEl	dd 0
_@mod_interf_cr_chunk_begin_stack_el	ends

;-------------------------------------------------------
;-------------------------------------------------------
_@mod_interf_cr_compute_len macro len
	local _@micclExit
			push ebx
			push ecx
			mov ebx,len
			xor eax,eax
			mov cl,8-2
		@@:
			shr ebx,cl
			test ebx,ebx
			jz short _@micclExit

			mov cl,8
			inc eax
			jmp short @b
	_@micclExit:
			pop ecx
			pop ebx
endm
;-------------------------------------------------------
_@stos_len		macro len,bytes
			push ebx
				push len
			mov ebx,bytes
			and bl,3
				pop eax
			shl eax,2
			or al,bl
			inc bl

		@@:
			stosb
			shr eax,8
			dec bl
			jnz short @b
			
			pop ebx
endm
;-------------------------------------------------------
_@mod_interf_cr_chunk_begin macro cnkBegPtr
			push cnkBegPtr
		_@getMem sizeof _@mod_interf_cr_chunk_begin_stack_el
		assume eax: ptr _@mod_interf_cr_chunk_begin_stack_el
			pop [eax].cnkPtr
			push lplpCrModInterf_chunk_begin
			pop [eax].lpNext_chunkBeg_stackEl
			mov lplpCrModInterf_chunk_begin,eax
endm
;-------------------------------------------------------
; eax=ptrNext
; ecx=shift (bytes)
_@mod_interf_cr_chunk_end proc cnkEndPtr
;correct chunk len
;			push ecx
			push edi

				push cnkEndPtr

			mov eax,lplpCrModInterf_chunk_begin
		assume eax: ptr _@mod_interf_cr_chunk_begin_stack_el
			mov ecx,[eax].lpNext_chunkBeg_stackEl
			mov lplpCrModInterf_chunk_begin,ecx
			mov ecx,[eax].cnkPtr
			mov lpCrModInterf_chunk_begin,ecx
		_@freeMem eax

				pop ecx
			mov edi,ecx
			sub ecx,lpCrModInterf_chunk_begin
		_@mod_interf_cr_compute_len ecx

			push ecx
			push eax

			inc eax
			add edi,eax

			push ecx		;len
			push lpCrModInterf_chunk_begin ;from
			add eax,lpCrModInterf_chunk_begin
			push eax		;to
			call ___@cpyMem

			pop eax
			pop ecx

			push edi
			mov edi,lpCrModInterf_chunk_begin
			xchg eax,ecx
		_@stos_len eax,ecx;ecx,eax
			pop edi

			inc ecx
			mov eax,edi

			pop edi
;			pop ecx
			ret
_@mod_interf_cr_chunk_end	endp
;-------------------------------------------------------
;-------------------------------------------------------
.data

lpCrModInterf			dd 0
CrModInterf_len			dd 0
CrModInterf_len_filled		dd 0
lpCrModInterf_cur_pointer	dd 0

lplpCrModInterf_chunk_begin	dd 0
lpCrModInterf_chunk_begin	dd 0
;lpCrModInterf_chunk_len		dd 0
;-------------------------------------------------------
.code
extrn code_start:near
extrn code_size:near


extrn my_apply_fixe@8:near	;fixeOffset,fixe
my_apply_fixe	equ my_apply_fixe@8

_@apply_fixes	proc lpFirstFixe,lpFixePointsTo,offsFromModuleOrg
			push eax
			push esi

			mov eax,lpFixePointsTo
			sub eax,lpCrModInterf
			add eax,offsFromModuleOrg
			mov esi,eax

			mov eax,lpFirstFixe
		assume eax: ptr _@module_fixe

	afFixesLoop_b:
			test eax,eax
			jz short afExit

;				push eax

			push esi
			push [eax].addr_to_fixe
			call my_apply_fixe
			;fixeOffset,fixe

;				pop eax

			mov eax,[eax].lpNextFixe
			jmp short afFixesLoop_b
			
	afExit:
			pop esi
			pop eax
			ret
_@apply_fixes	endp
;-------------------------------------------------------
_@apply_module_fixes	proc lpModule,offsFromModuleOrg,addition_offset
			push edi
			push esi

			mov eax,lpModule
			test eax,eax
			jz  amfExit;short
			mov esi,eax
		assume esi: ptr _@module

			mov eax,addition_offset
			add eax,[esi].offset_from_begin
			push eax
	smIsNeedCall_ToRead:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_READ
			jz short @f

			pop eax
			push eax
			add eax,[esi].offset_from_begin_r

			push offsFromModuleOrg
			push eax
			push [esi].lpCallback_toRead_first_fixe
			call _@apply_fixes
			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toRead
		@@:
	smIsNeedCall_ToWrite:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_WRITE
			jz short @f

			pop eax
			push eax
			add eax,[esi].offset_from_begin_w

			push offsFromModuleOrg
			push eax
			push [esi].lpCallback_toWrite_first_fixe
			call _@apply_fixes
			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toWrite
		@@:
	smIsNeedCall_ToCall:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_CALL
			jz short @f

			pop eax
			push eax
			add eax,[esi].offset_from_begin_c

			push offsFromModuleOrg
			push eax
			push [esi].lpCallback_toCall_first_fixe
			call _@apply_fixes
			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toCall
		@@:
			pop eax

			mov eax,addition_offset
;			add eax,[esi].offset_from_begin

;printfX 01ff1h
		;------------------------------
			push esi
			mov esi,[esi].lpRequiredFirstModule
	amfRequiredModulesApplyFixesLoop_b:
			test esi,esi
			jz short amfRequiredModulesApplyFixesLoop_e

;printfX 01ff2h
			push eax

			push eax
			push offsFromModuleOrg
			push esi
			call _@apply_module_fixes

			pop eax

;			add eax,[esi].offset_from_begin

			mov esi,[esi].lpNextModule

			jmp short amfRequiredModulesApplyFixesLoop_b
	amfRequiredModulesApplyFixesLoop_e:
			pop esi

;correcting postfixes
	mov edi,[esi].lpFirstOffsetToInterfVarFixe
@@:
assume edi: ptr _@module_fixe
	test edi,edi
	jz short @f
;printfX 01ff3h

	push eax
	push [edi].addr_to_fixe
	call my_set_to_interface_pointer
	;lp_place_to_set,interf_inside_offset

	mov edi,[edi].lpNextFixe

	jmp short @b
@@:


	amfExit:
			pop esi
			pop edi
			ret
_@apply_module_fixes		endp
;-------------------------------------------------------
;-------------------------------------------------------
;_@apply_mod__memb_fixes	proc lpModMemb,offsFromModuleOrg,addition_offset
;			push edi
;			push esi
;
;			mov eax,lpModMemb
;			test eax,eax
;			jz  amfExit;short
;			mov esi,eax
;		assume esi: ptr _@module_member
;
;			mov eax,addition_offset
;			add eax,[esi].offset_from_begin
;			push eax
;	ammfIsNeedCall_ToRead:
;			test [esi].memb_flags,MOD_MEMB_ACCESS_READ
;			jz short @f
;
;			pop eax
;			push eax
;			add eax,[esi].offset_from_begin_r
;
;			push offsFromModuleOrg
;			push eax
;			push [esi].lpCallback_toRead_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg
;
;			mov eax,[esi].lpCallback_toRead
;		@@:
;	smIsNeedCall_ToWrite:
;			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_WRITE
;			jz short @f
;
;			pop eax
;			push eax
;			add eax,[esi].offset_from_begin_w
;
;			push offsFromModuleOrg
;			push eax
;			push [esi].lpCallback_toWrite_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg
;
;			mov eax,[esi].lpCallback_toWrite
;		@@:
;	smIsNeedCall_ToCall:
;			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_CALL
;			jz short @f
;
;			pop eax
;			push eax
;			add eax,[esi].offset_from_begin_c
;
;			push offsFromModuleOrg
;			push eax
;			push [esi].lpCallback_toCall_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg
;
;			mov eax,[esi].lpCallback_toCall
;		@@:
;			pop eax
;
;			mov eax,addition_offset
;;			add eax,[esi].offset_from_begin
;
;
;	amfExit:
;			pop esi
;			pop edi
;			ret
;_@apply_mod__memb_fixes	endp
;-------------------------------------------------------
; -> eax = module interface begin
; -> ecx = module interface len
module_interface_create	proc lpModule,offsFromModuleOrg
			push edi
			push esi
			push ebx
;			push ecx
			push edx

			mov eax,lpModule
			test eax,eax
			jz  micExit;short
			mov esi,eax
		assume esi: ptr _@module

;			xor eax,eax
;			mov CrModInterf_len_filled,eax
;			xchg eax,lpCrModInterf
;			test eax,eax
;			jz short @f
;		_@freeMem eax
;		@@:

;int 3
mov eax,dword ptr [code_start]
;mov ebx,dword ptr [code_size]
;			mov edi,MOD_INTERF_CR_BEGINING_SIZE
;		_@getMem edi
			test eax,eax
			jz  micExit;short

;			mov CrModInterf_len,edi

add eax,offsFromModuleOrg
			mov lpCrModInterf,eax
;			add eax,MOD_INTERF_CREATING_OFFSET
			mov lpCrModInterf_cur_pointer,eax
			mov edi,eax

		_@mod_interf_cr_chunk_begin edi

	micStoreSelfModuleInterf:
			push offsFromModuleOrg
			push edi
			push esi
			call _@store_module
			mov edi,eax

			mov esi,[esi].lpRequiredFirstModule
	micStoreRequiredModulesInterfaces:
			test esi,esi
			jz short micFinishStoringInterface

			push offsFromModuleOrg
			push edi
			push esi
			call _@store_module
			mov edi,eax

			mov esi,[esi].lpNextModule

			jmp short micStoreRequiredModulesInterfaces
	micFinishStoringInterface:

;interface size store
;			mov esi,lpModule

			push edi
			call _@mod_interf_cr_chunk_end 
			mov edi,eax

;			add ecx,MOD_INTERF_CREATING_OFFSET
;			add [esi].offset_from_begin,ecx
		push ecx

			sub eax,lpCrModInterf
			push eax		;len
			mov eax,lpCrModInterf
			push eax		;from
			add eax,MOD_INTERF_CREATING_OFFSET
			push eax		;to
			call ___@cpyMem

			push edi
			
			mov edi,lpCrModInterf
			mov eax,MOD_INTERF_MAGIC
			mov cl,MOD_INTERF_MAGIC_LEN
		@@:
			stosb
			shr eax,8
			dec cl
			jnz short @b

			mov al,MOD_INTERF_VERSION
			stosb

			pop edi
			add edi,MOD_INTERF_CREATING_OFFSET

		pop ecx
		add ecx,MOD_INTERF_CREATING_OFFSET

		push ecx;0
		push offsFromModuleOrg
		push lpModule
		call _@apply_module_fixes

		push offsFromModuleOrg
		push edi
		push lpModule
		call _@createOriginFixesTable
		mov edi,eax

			mov eax,lpCrModInterf
			mov ecx,edi
			sub ecx,lpCrModInterf
	micExit:
			pop edx
;			pop ecx
			pop ebx
			pop esi
			pop edi
			ret
module_interface_create		endp
;-------------------------------------------------------
_@store_module	proc lpModule,lpPlace,offsFromModuleOrg
			push esi
			push edi
			push ecx
			push edx

			mov eax,lpPlace
			test eax,eax
			jz  smExit;short
			mov edi,eax

			mov eax,lpModule
			test eax,eax
			jz  smExit;short
			mov esi,eax
		assume esi: ptr _@module


		_@mod_interf_cr_chunk_begin edi
;module name store
			push [esi].lpszModuleName
			call strlen
;			add esp,4

			test eax,eax
			jz short @f
			inc eax
		@@:
			mov ecx,eax
		_@mod_interf_cr_compute_len eax
;			mov ebx,eax
		_@stos_len ecx,eax
;			add edi,ebx

			push ecx	;len
			push [esi].lpszModuleName ;from
			push edi	;to
		add edi,ecx
			call ___@cpyMem

;module doc store
			push [esi].lpszModuleDoc
			call strlen
;			add esp,4

			test eax,eax
			jz short @f
			inc eax
		@@:
			mov ecx,eax
		_@mod_interf_cr_compute_len eax
;			mov ebx,eax
		_@stos_len ecx,eax

			push ecx	;len
			push [esi].lpszModuleDoc ;from
			push edi	;to
		add edi,ecx
			call ___@cpyMem


			xor edx,edx
;			xor eax,eax
			xor ecx,ecx
	smIsNeedCall_ToRead:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_READ
			jz short @f

			mov cl,4
		@@:
		_@stos_len ecx,0 ;edx
			test ecx,ecx
			jz short @f

		mov eax,edi
;		sub eax,lpCrModInterf
		mov [esi].offset_from_begin_r,eax

;			push offsFromModuleOrg
;			push edi
;			push [esi].lpCallback_toRead_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toRead
			xor eax,eax
			stosd

		@@:
;			xor edx,edx
			xor ecx,ecx
	smIsNeedCall_ToWrite:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_WRITE
			jz short @f

			mov cl,4
		@@:
		_@stos_len ecx,0 ;edx
			test ecx,ecx
			jz short @f

		mov eax,edi
;		sub eax,lpCrModInterf
		mov [esi].offset_from_begin_w,eax

;			push offsFromModuleOrg
;			push edi
;			push [esi].lpCallback_toWrite_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toWrite
			xor eax,eax
			stosd
		@@:
;			xor edx,edx
			xor ecx,ecx
	smIsNeedCall_ToCall:
			test [esi].module_flags,MOD_FL_NEEDS_CALL_TO_CALL
			jz short @f

			mov cl,4
		@@:
		_@stos_len ecx,0 ;edx
			test ecx,ecx
			jz short @f

		mov eax,edi
;		sub eax,lpCrModInterf
		mov [esi].offset_from_begin_c,eax

;			push offsFromModuleOrg
;			push edi
;			push [esi].lpCallback_toCall_first_fixe
;			call _@apply_fixes
;			;lpFirstFixe,lpFixePointsTo,offsFromModuleOrg

;			mov eax,[esi].lpCallback_toCall
			xor eax,eax
			stosd
		@@:
			

;store module members
		push esi
		mov esi,[esi].lpFirstMember
	assume esi: ptr _@module_member

	smModuleMembersStoreLoop_b:
		test esi,esi
		jz short smModuleMembersStoreLoop_e

		push offsFromModuleOrg
		push edi
		push esi
		call _@store_module_member
		mov edi,eax

		mov esi,[esi].lpNextModuleMember

		jmp short smModuleMembersStoreLoop_b
	smModuleMembersStoreLoop_e:
		pop esi
	assume esi: ptr _@module

;store chunk len
			push edi
			call _@mod_interf_cr_chunk_end 
			mov edi,eax
			mov [esi].offset_from_begin,ecx

;correcting postfixes
	mov eax,[esi].lpFirstOffsetToInterfVarFixe
@@:
assume eax: ptr _@module_fixe
	test eax,eax
	jz short @f

	push ecx
	push [eax].addr_to_fixe
	call my_set_to_interface_pointer
	;lp_place_to_set,interf_inside_offset

	mov eax,[eax].lpNextFixe

	jmp short @b
@@:


	smExit:
			mov eax,edi
			pop edx
			pop ecx
			pop edi
			pop esi
			ret
_@store_module		endp
;-------------------------------------------------------
extern my_set_to_interface_pointer@8:near
my_set_to_interface_pointer equ my_set_to_interface_pointer@8
	;lp_place_to_set,interf_inside_offset
_@store_module_member	proc lpModMemb,lpPlace,offsFromModuleOrg
			push esi
			push edi
			push ebx
			push ecx
			push edx

			mov eax,lpPlace
			test eax,eax
			jz  smExit;short
			mov edi,eax

			mov eax,lpModMemb
			test eax,eax
			jz  smExit;short
			mov esi,eax
		assume esi: ptr _@module_member


		_@mod_interf_cr_chunk_begin edi
;module member name store
			push [esi].lpszModMembName
			call strlen
;			add esp,4

			test eax,eax
			jz short @f
			inc eax
		@@:
			mov ecx,eax
		_@mod_interf_cr_compute_len eax
;			mov ebx,eax
		_@stos_len ecx,eax
;			add edi,ebx

push edi ;for postfixes - memb name

			push ecx	;len
			push [esi].lpszModMembName ;from
			push edi	;to
		add edi,ecx
			call ___@cpyMem

;module member doc store
			push [esi].lpszModMembDoc
			call strlen
;			add esp,4

			test eax,eax
			jz short @f
			inc eax
		@@:
			mov ecx,eax
		_@mod_interf_cr_compute_len eax
;			mov ebx,eax
		_@stos_len ecx,eax

			push ecx	;len
			push [esi].lpszModMembDoc ;from
			push edi	;to
		add edi,ecx
			call ___@cpyMem

;module member type
;   bites 0-2:
;	1 - byte [1 byte]
;	2 - word [2 byte]
;	3 - dword [4 byte]
;	4 - word+dword (far pointer) [6 byte]
;	5 - qword [8 byte] eax+edx
;	6 - qword [8 byte] rax ??
;	7 - string (lp ASCIIZ) [4 byte]
;   bit 6:
;	1 - pointer
;   bit 7:
;     if bites (0-2)!=0
;	0 - unsigned
;	1 - signed
;     if bites (0-2)==0
;	0 - function [4 bytes]
;	1 - double float [10 bytes] fpu top
			mov eax,[esi].memb_type
			stosb
			push eax
		_@mod_interf_cr_chunk_begin edi
			pop eax
			test al,al
			jnz  smmAfterStoreFuncParamsReturnsTypes;short
;if member function store params and returns after
		_@mod_interf_cr_chunk_begin edi
			mov ebx,[esi].func_params_types_list_len
			mov edx,[esi].lp_func_params_types_list
			test edx,edx
			jz short smmStoreParams_e
			inc ebx
		smmStoreParams_b:
			dec ebx
			jz short smmStoreParams_e
			mov al,byte ptr [edx]
			stosb
			inc edx
			jmp short smmStoreParams_b
		smmStoreParams_e:
			
			push edi
			call _@mod_interf_cr_chunk_end
			mov edi,eax

		_@mod_interf_cr_chunk_begin edi
			mov ebx,[esi].func_returns_types_list_len
			mov edx,[esi].lp_func_returns_types_list
			test edx,edx
			jz short smmStoreReturns_e
			inc ebx
		smmStoreReturns_b:
			dec ebx
			jz short smmStoreReturns_e
			mov al,byte ptr [edx]
			stosb
			inc edx
			jmp short smmStoreReturns_b
		smmStoreReturns_e:
			
			push edi
			call _@mod_interf_cr_chunk_end
			mov edi,eax
	smmAfterStoreFuncParamsReturnsTypes:
			push edi
			call _@mod_interf_cr_chunk_end
			mov edi,eax

;place for pointer to real object (4 bytes)
;			xor eax,eax
			mov eax,[esi].lpAddress
push edi ;for postfixes - pointer to real object
			stosd

;store chunk len
			push edi
			call _@mod_interf_cr_chunk_end 
			mov edi,eax
			mov [esi].offset_from_begin,ecx

;preparing postfixes
	mov eax,lpCrModInterf
	sub eax,offsFromModuleOrg
;	sub eax,MOD_INTERF_CREATING_OFFSET
	sub eax,ecx

	pop ecx
	sub ecx,eax
;ecx=offset from begin interf to pointer to real object
	pop ebx
	sub ebx,eax
;ebx=offset from begin interf to memb name

	push edi

	mov edi,[esi].lpModule
assume edi: ptr _@module

	xor eax,eax
	xchg eax,[esi].lpFirstPostfixe_r
	mov edx,ecx
	test [edi].module_flags,MOD_FL_NEEDS_CALL_TO_READ
	jz short @f
	mov edx,ebx
@@:
	call smmPreparePostfixes

	xor eax,eax
	xchg eax,[esi].lpFirstPostfixe_w
	mov edx,ecx
	test [edi].module_flags,MOD_FL_NEEDS_CALL_TO_WRITE
	jz short @f
	mov edx,ebx
@@:
	call smmPreparePostfixes

	xor eax,eax
	xchg eax,[esi].lpFirstPostfixe_c
	mov edx,ecx
	test [edi].module_flags,MOD_FL_NEEDS_CALL_TO_CALL
	jz short @f
	mov edx,ebx
@@:
	call smmPreparePostfixes

	jmp short smmAfterPreparePostfixes


smmPreparePostfixes:
@@:
assume eax: ptr _@module_fixe
	test eax,eax
	jz short @f

	push edx
	push [eax].addr_to_fixe
	call my_set_to_interface_pointer
	;lp_place_to_set,interf_inside_offset

	push [eax].lpNextFixe

	push [edi].lpFirstOffsetToInterfVarFixe
	mov [edi].lpFirstOffsetToInterfVarFixe,eax
	pop [eax].lpNextFixe

	pop eax
	jmp short @b
@@:
	db 0c3h	;ret

smmAfterPreparePostfixes:
	pop edi


	smExit:
			mov eax,edi
			pop edx
			pop ecx
			pop ebx
			pop edi
			pop esi
			ret
_@store_module_member		endp
;-------------------------------------------------------
;extrn my_get_code_start:near
_@createOriginFixesTable	proc lpModule,lpPlace,offsFromModuleOrg
			push esi
			push edi
			push ebx
			push ecx
			push edx

			mov eax,lpPlace
			test eax,eax
			jz  coftExit;short
			mov edi,eax

			mov eax,lpModule
;			test eax,eax
;			jz short coftExit;
			mov esi,eax
		assume esi: ptr _@module
;			push esi
			
			test esi,esi
			jz  coftSetOriginQuestTableSize;short

;			pop eax

		_@mod_interf_cr_chunk_begin edi

			push [esi].lpRequiredFirstModule

	coftCreateOriginQuestTable:
;			test esi,esi
;			jz  coftSetOriginQuestTableSize;short

;correct call fixes and move call fixes to origin fixes
;			mov ecx,0;dword ptr [code_start]

		assume ebx: ptr _@module_fixe
			lea eax,[esi].lpFirstOriginFixe
		@@:
			mov ebx,dword ptr [eax]
			test ebx,ebx
			jz short @f
			lea eax,[ebx].lpNextFixe
			jmp short @b
		@@:
			xchg ebx,[esi].lpCallback_toRead_first_fixe
			mov dword ptr [eax],ebx
		@@:
			test ebx,ebx
			jz short @f
			lea eax,[ebx].lpNextFixe
			mov ebx,dword ptr [eax]
			jmp short @b
		@@:
			xchg ebx,[esi].lpCallback_toWrite_first_fixe
			mov dword ptr [eax],ebx
		@@:
			test ebx,ebx
			jz short @f
			lea eax,[ebx].lpNextFixe
			mov ebx,dword ptr [eax]
			jmp short @b
		@@:
			xchg ebx,[esi].lpCallback_toCall_first_fixe
			mov dword ptr [eax],ebx
;		@@:
;			test ebx,ebx
;			jz short @f
;			lea eax,[ebx].lpNextFixe
;			mov ebx,dword ptr [eax]
;			jmp short @b
;		@@:



;			mov edx,[esi].lpFirstOriginFixe
;			lea eax,[esi].lpCallback_toRead_first_fixe
;		@@:
;			mov ebx,dword ptr [eax]
;			test ebx,ebx
;			jz short @f
;			sub [ebx].addr_to_fixe,ecx
;			lea eax,[ebx].lpNextFixe
;			jmp short @b
;		@@:
;			mov dword ptr [eax],edx
;			xor edx,edx
;			xchg edx,[esi].lpCallback_toRead_first_fixe
;
;			lea eax,[esi].lpCallback_toWrite_first_fixe
;		@@:
;			mov ebx,dword ptr [eax]
;			test ebx,ebx
;			jz short @f
;			sub [ebx].addr_to_fixe,ecx
;			lea eax,[ebx].lpNextFixe
;			jmp short @b
;		@@:
;			mov dword ptr [eax],edx
;			xor edx,edx
;			xchg edx,[esi].lpCallback_toWrite_first_fixe
;
;			lea eax,[esi].lpCallback_toCall_first_fixe
;		@@:
;			mov ebx,dword ptr [eax]
;			test ebx,ebx
;			jz short @f
;			sub [ebx].addr_to_fixe,ecx
;			lea eax,[ebx].lpNextFixe
;			jmp short @b
;		@@:
;			mov dword ptr [eax],edx
;			xor edx,edx
;			xchg edx,[esi].lpCallback_toCall_first_fixe
;
;			mov [esi].lpFirstOriginFixe,edx

;create origin fixes table
			mov ebx,[esi].lpFirstOriginFixe
		assume ebx: ptr _@module_fixe

	coftModuleOriginQuestTableCreate_b:
			test ebx,ebx
			jz short coftModuleOriginQuestTableCreate_e

			mov ecx,[ebx].addr_to_fixe

		_@mod_interf_cr_compute_len ecx
		_@stos_len ecx,eax

			mov ebx,[ebx].lpNextFixe
			jmp short coftModuleOriginQuestTableCreate_b
	coftModuleOriginQuestTableCreate_e:

			mov ebx,[esi].lpFirstOffsetToInterfVarFixe
		assume ebx: ptr _@module_fixe

	coftModuleOffsToInterfVarQuestTableCreate_b:
			test ebx,ebx
			jz short coftModuleOffsToInterfVarQuestTableCreate_e

			mov ecx,[ebx].addr_to_fixe

		_@mod_interf_cr_compute_len ecx
		_@stos_len ecx,eax

			mov ebx,[ebx].lpNextFixe
			jmp short coftModuleOffsToInterfVarQuestTableCreate_b
	coftModuleOffsToInterfVarQuestTableCreate_e:

			pop esi
			
			test esi,esi
			jz short coftSetOriginQuestTableSize;

			push [esi].lpNextModule
;			mov esi,[esi].lpRequiredFirstModule
			jmp  coftCreateOriginQuestTable;short

	coftSetOriginQuestTableSize:
;store chunk len
			push edi
			call _@mod_interf_cr_chunk_end 
			mov edi,eax


;;module name store
;			push [esi].lpszModuleName
;			call strlen
;
;			test eax,eax
;			jz short @f
;			inc eax
;		@@:
;			mov ecx,eax
;		_@mod_interf_cr_compute_len eax
;		_@stos_len ecx,eax
;
;			push ecx	;len
;			push [esi].lpszModuleName ;from
;			push edi	;to
;		add edi,ecx
;			call ___@cpyMem
;
;
;;store chunk len
;			push edi
;			call _@mod_interf_cr_chunk_end 
;			mov edi,eax
;			mov [esi].offset_from_begin,ecx

	coftExit:
			mov eax,edi
			pop edx
			pop ecx
			pop ebx
			pop edi
			pop esi
			ret
_@createOriginFixesTable	endp
;-------------------------------------------------------
_@createAdditionTagsList	proc lpModule,lpPlace,offsFromModuleOrg
			push esi
			push edi
			push ebx
			push ecx
			push edx

			mov eax,lpPlace
			test eax,eax
			jz short catlExit;
			mov edi,eax

		_@mod_interf_cr_chunk_begin edi

;create tags..

	catlSetOriginQuestTableSize:
;store chunk len
			push edi
			call _@mod_interf_cr_chunk_end 
			mov edi,eax

	catlExit:
			mov eax,edi
			pop edx
			pop ecx
			pop ebx
			pop edi
			pop esi
			ret
_@createAdditionTagsList	endp
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------
;-------------------------------------------------------

